package com.hx.petsever.impl;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hx.petsever.entity.Info;
import com.hx.petsever.mapper.InfoMapper;
import com.hx.petsever.service.InfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InfoServiceImpl extends ServiceImpl<InfoMapper,Info>  implements InfoService {

    @Autowired
    InfoMapper infoMapper;

    @Override
    public Info getInfo(String userid) {
        Info info = infoMapper.getInfo(userid);
        return info;
    }

    @Override
    public Info update(Info info) {
        Info in = infoMapper.getInfo(info.getUserid());
        if(in == null)
            infoMapper.insert(info);
        else{
            infoMapper.updateInfo(info.getUserid(),info.getSex(),info.getAge(),info.getHabit());
        }
        return info;
    }
}
